//
//  MenuScene.m
//  menuTutorial
//
//  Created by Greg Dunn on 9/7/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "SSMenuScene.h"
#import "SSLevelSelectScene.h"
#import "SSOptionsScene.h"
#import "SSInstructionsScene.h"
#import "SSHighScoreScene.h"
#import "SSCreditsScene.h"
#import "SSLogoLayer.h"
#import "SSGameScene.h"
#import "SSMoreGameScene.h"
#import "SSGlobal.h"

@implementation SSMenuScene

@synthesize haveLevelSelect;

- (id) init
{
	self = [super init];
	if (self != nil) {
		CGSize size = [[CCDirector sharedDirector] winSize];
		
		CCSprite *bg = [CCSprite spriteWithFile:@"background.png"];
		bg.position = ccp(size.width /2, size.height/2);
		[self addChild:bg];	
		
		SSLogoLayer *logoLayer = [SSLogoLayer node];
        [self addChild:logoLayer];
		
		//[CCMenuItemFont setFontName:@"Arial"];
		[CCMenuItemFont setFontSize:20];

		CCMenuItem *menuItem1 = [CCMenuItemFont itemFromString:NSLocalizedString(@"Start Game", @"Start Game") target:self selector:@selector(onGame:)];
		CCMenuItem *menuItem2 = [CCMenuItemFont itemFromString:NSLocalizedString(@"Options", @"Options") target:self selector:@selector(onOptions:)];
		CCMenuItem *menuItem3 = [CCMenuItemFont itemFromString:NSLocalizedString(@"Instructions", @"Instructions") target:self selector:@selector(onInstructions:)];
		CCMenuItem *menuItem4 = [CCMenuItemFont itemFromString:NSLocalizedString(@"High Score", @"High Score") target:self selector:@selector(onHighScore:)];
		CCMenuItem *menuItem5 = [CCMenuItemFont itemFromString:NSLocalizedString(@"Credits", @"Credits") target:self selector:@selector(onCredits:)];
		CCMenuItem *menuItem6 = [CCMenuItemFont itemFromString:NSLocalizedString(@"More Game", @"More Game") target:self selector:@selector(onMoreGame:)];

		
		CCMenu *menu = [CCMenu menuWithItems:menuItem1, menuItem2, menuItem3, menuItem4,menuItem5,menuItem6, nil];
		[menu alignItemsVerticallyWithPadding:10];
		menu.position = ccp(size.width /2, size.height/2);
		[self addChild:menu];
		
		[self setHaveLevelSelect:NO];
	}
	return self;
}
- (void)onGame:(id)sender
{
	CMLog(@"on game");
	[[SSGlobal instance] clickButton];
	
	if ([self isHaveLevelSelect]) {
		[[CCDirector sharedDirector] replaceScene:[SSLevelSelectScene node]];
	}else {
		[[CCDirector sharedDirector] replaceScene:[SSGameScene node]];
	}

	
}
- (void)onOptions:(id)sender
{
	[[SSGlobal instance] clickButton];
	
	CMLog(@"on options");
	[[CCDirector sharedDirector] replaceScene:[SSOptionsScene node]];
}
- (void)onInstructions:(id)sender
{
	[[SSGlobal instance] clickButton];
	
	CMLog(@"on instructions");
	[[CCDirector sharedDirector] replaceScene:[SSInstructionsScene node]];
}
- (void)onHighScore:(id)sender
{
	[[SSGlobal instance] clickButton];
	
	CMLog(@"on high scores");
	[[CCDirector sharedDirector] replaceScene:[SSHighScoreScene node]];
}
- (void)onCredits:(id)sender
{
	[[SSGlobal instance] clickButton];
	
	CMLog(@"on credits");
	[[CCDirector sharedDirector] replaceScene:[SSCreditsScene node]];
}
- (void)onMoreGame:(id)sender
{
	[[SSGlobal instance] clickButton];
	
	CMLog(@"on credits");
	[[CCDirector sharedDirector] replaceScene:[SSMoreGameScene node]];
}
@end
